package com.kuang.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Controller
@RequestMapping("/ajax")
public class AjaxController {

    //第一种方式，服务器要返回一个字符串，使用response。
    @RequestMapping("/a1")
    public void Ajax1(String name, HttpServletResponse response) throws IOException {
        if("admin".equals(name)){
             response.getWriter().println("true");
        }else {
             response.getWriter().println("false");
        }
    }
    @RequestMapping("/a2")
    public void Ajax2(String pwd, HttpServletResponse response) throws IOException {
        System.out.println(pwd);
        if("admin".equals(pwd)){
            response.getWriter().println("true");
        }else {
            response.getWriter().println("false");
        }
    }
}
